# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=borgmatic
pkgver=1.8.6
pkgrel=0
pkgdesc="Simple, configuration-driven backup software for servers and workstations"
url="https://torsion.org/borgmatic/"
license="GPL-3.0-or-later"
# armhf: limited by borgbackup
# s390x: tests fail
arch="noarch !armhf !s390x"
depends="
	borgbackup
	py3-colorama
	py3-jsonschema
	py3-packaging
	py3-requests
	py3-ruamel.yaml
	"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-wheel
	"
checkdepends="
	py3-pytest
	py3-pytest-cov
	py3-flexmock
	"
subpackages="$pkgname-bash-completion $pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://projects.torsion.org/borgmatic-collective/borgmatic/archive/$pkgver.tar.gz
	python3.patch
	"
builddir="$srcdir/borgmatic"


build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2

	python3 -m venv --clear --without-pip --system-site-packages venv
	./venv/bin/python3 -m installer \
		.dist/borgmatic-$pkgver-py3-none-any.whl
	./venv/bin/borgmatic --bash-completion > $pkgname.bash
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	# Requires unpackaged apprise module
	PATH="$PATH:$builddir/.testenv/bin" .testenv/bin/python3 -m pytest \
		--ignore=tests/unit/hooks/test_apprise.py
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/borgmatic-$pkgver-py3-none-any.whl

	install -Dm644 $pkgname.bash \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname
}

sha512sums="
31cf91ecfa36fefcc95885b8775ffd1bc2f4c1b7b234619582e565135ec6f1198e8747c411e4e40133240a98ca204d1106c3b92b95cc2a545a6b2004ec5fd8b0  borgmatic-1.8.6.tar.gz
c4561ec75f486f75121f18039e42b166ed7eac4f3a6a2e821410ec0b8f0d1a48f1e5155393d8b735b6554efcf9cfc8ff163bc64b262b0239f86a03ec59ab6652  python3.patch
"
